package ferp.core.player;

import ferp.core.game.Bid;
import ferp.core.game.Game;
import ferp.core.game.Input;
import ferp.core.game.Settings;
import ferp.core.state.State;
import ferp.core.tutorial.Scenario;

/**
 * User: olegs
 * Date: 20/11/2014 21:34
 */
public class Actor extends Robot
{
  public Actor(Game g, int id, String name)
  {
    super(g, id, name);

    scenario = g.scenario();
  }

  @Override
  public int setBiddingInputOptions(Game g, Input.Options io)
  {
    io.set(Input.Options.WAIT_FOR_TOUCH);

    return State.Result.SHOW_OPTIONS;
  }

  @Override
  public int setDroppingInputOptions(Game g, Settings settings, Input input, Input.Options io)
  {
    io.set(Input.Options.WAIT_FOR_TOUCH);

    return State.Result.SHOW_OPTIONS;
  }

  @Override
  public int setContractingInputOptions(Game g, Input.Options io)
  {
    io.set(Input.Options.WAIT_FOR_TOUCH);

    return State.Result.SHOW_OPTIONS;
  }

  @Override
  public int setContractingInputOptionsCheck10(Input.Options io) {return State.Result.SCHEDULE;}

  @Override
  public void bid(Game.Listener listener, Game g, Settings settings, Input input)
  {
    Bid bid = scenario.bid(g.rounds, id());

    g.setBid(id(), bid, new Bid(bid));
  }

  @Override
  public void contract(Game g, Settings settings, Input input)
  {
    Bid bid = scenario.contract(g.rounds, id());

    g.setBid(id(), bid, bid);
  }

  @Override
  public void drop(Game g, Input input) {g.setDrop(scenario.drop());}

  @Override
  public int setStandInputOptions(Input.Options io) {return State.Result.SCHEDULE;}

  @Override
  public void setGameType(Game g, Input input) {g.type = Game.Type.OPEN;}

  @Override
  public void setCheck10(Game g, Input input){}

  public void setPassingInputOptions(Game.Listener listener, Game g) throws Game.Error {}
  public void setMisereInputOptions(Game.Listener listener, Game g) throws Game.Error {}
  public void setTrickingInputOptions(Game.Listener listener, Game g) throws Game.Error {}

  private Scenario scenario;
}
